# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=python-cookiecutter
pkgname=('python2-cookiecutter' 'python-cookiecutter')
_pkgname=cookiecutter
pkgver=2.6.0
pkgrel=2
pkgdesc='A command-line utility that creates projects from cookiecutters (project templates).'
arch=('any')
url='https://pypi.org/project/cookiecutter/#files'
license=('BSD')
makedepends=('python2-setuptools' 'python-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('a42c44bd65eb43437b1427a6d68dc089ee9afb93917aca35ddc8db135cbfb6db2779f0f96b99cacb575eb01a97e400567254963978b927ad4ca012896bd0f78f')

prepare() {
  cp -a "$_pkgname-$pkgver"{,-2}

  cd "$_pkgname-$pkgver-2"

  grep -iRl 'python' * | xargs \
    sed -i 's|#!.*/usr/bin/python|#!/usr/bin/python2|;s|#!.*/usr/bin/env python$|#!/usr/bin/env python2|'
}

package_python2-cookiecutter() {
  depends=('python2-future' 'python2-jinja' 'python2-yaml' 'python2-binaryornot'
           'python2-click' 'python2-poyo' 'python2-requests'
           'python2-jinja-time' 'python2-whichcraft')

  cd "$_pkgname-$pkgver-2"

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  mv "$pkgdir/usr/bin/$_pkgname" "$pkgdir/usr/bin/${_pkgname}2"
}

package_python-cookiecutter() {
  depends=('python-future' 'python-jinja' 'python-yaml' 'python-binaryornot'
           'python-click' 'python-poyo' 'python-requests' 'python-jinja-time'
           'python-whichcraft')

  cd "$_pkgname-$pkgver"

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build
}

